package org.ece3574.WTParty;

public class GeoLocation {
	
	public static GeoLocation getFromString(String location)
	{
		if(location==null)
			return null;
		String[] sp = location.split(",");
		if(sp.length<3)
			return null;
		try
		{
			int lat = Integer.parseInt(sp[1]);
			int lon = Integer.parseInt(sp[2]);
			GeoLocation loc = new GeoLocation(sp[0], lat, lon);
			return loc;
		}
		catch(NumberFormatException e)
		{
			return null;
		}
		
		
	}
	
	public String toString()
	{
		return String.format("%1$s,%2$d,%3$d", name, latitude, longitude);
	}
	
	public GeoLocation(String n, int lat, int lon)
	{
		latitude = lat;
		longitude = lon;
		name = n;
	}
	public int latitude;
	public int longitude;
	public String name;

}
